package com.ldn.basic.enumeration;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 李大牛家的牛 (scafel@163.com) 
 * @createDate 2024/8/15 - 12:26
 * @description ...
 **/
@Schema(description = "使用String枚举")
@Getter
public enum UseStringEnum {

    // 增加
    INCREASE("INCREASE", "增加", 1),
    // 减少
    DECREASE("DECREASE", "减少", 2),


    // 系统赠送
    SYSTEM_GIFT("SYSTEM_GIFT", "系统赠送", 6),
    // 商城购买
    SHOP_BUY("SHOP_ORDER_BUY", "购买", 1),
    // 赏购买
    ACGN_BUY("ACGN_ORDER_BUY", "购买", 1),
    // 开箱
    ACGN_OPEN_BX("ACGN_OPEN_BX", "开宝箱", 1),
    // 赏抽奖‘
    ACGN_LOTTERY("ACGN_ORDER_LOTTERY", "抽奖", 2),
    // 转赠
    ACGN_TRANSFER("ACGN_ORDER_TRANSFER", "转赠", 2),
    // 回收
    ACGN_RECYCLE("ACGN_ORDER_RECYCLE", "回收", 1),
    // 赠送
    ACGN_TRANSFER_GIVE("ACGN_ORDER_TRANSFER_GIVE", "赠送", 2),
    // 发货
    ACGN_DELIVERY("ACGN_ORDER_DELIVERY", "发货", 1),
    //

    // 在
    IN_HAND("ORDER_IN_HAND", "在", 1),
    // 不在
    NOT_IN_HAND("ORDER_NOT_IN_HAND", "不在", 0),

    // 为自己助力
    ACGN_ASSIST_SELF("ACGN_ASSIST_SELF", "自己助力", 1),
    // 帮助别人
    ACGN_ASSIST_OTHER("ACGN_ASSIST_OTHER", "帮助别人", 2),
    // 用户自己
    USER("USER", "用户自己", 3),
    // 系统
    SYSTEM("SYSTEM", "系统", 4),
    // 测试
    TEST("TEST", "测试", 3),

    // 无
    DEFAULT("DEFAULT", "无", 0),

    UNKNOWN("UNKNOWN", "未知", -1),
    ;

    private static final Map<String, UseStringEnum> codeToEnumMap = new HashMap<>();

    static {
        for (UseStringEnum type : UseStringEnum.values()) {
            codeToEnumMap.put(type.getCode(), type);
        }
    }

    private final String code;
    /**
     * 自定义描述
     **/
    private final String message;

    private final Integer value;

    UseStringEnum(String code, String message, int value) {
        this.code = code;
        this.message = message;
        this.value = value;
    }

    public static UseStringEnum getType(String code) {
        UseStringEnum type = codeToEnumMap.get(code.toUpperCase());
        if (type == null) {
            return UseStringEnum.UNKNOWN;
        }
        return type;
    }
}
